<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        div{
            width: 50px;
            height: 50px;
            background: palegreen;
            text-align: center;
            line-height: 50px;
            position: fixed;
            right: 50px;
            bottom: 50px;
            display: none;
        }
    </style>
</head>
<body style="height: 10000px;">
    <div>top</div>
    <script>
        var div = document.querySelector('div');
        window.onscroll = function(){
            var h = window.innerHeight;
            var h1 = document.body.scrollTop || document.documentElement.scrollTop
            console.log(h,h1)
            // if(h1 >= h){
            //     div.style.display = 'block'
            // }else{
            //     div.style.display = 'none'
            // }
            div.style.display = h1>=h ? 'block' : 'none'
        }
        div.onclick = function(){
            var h2 = document.body.scrollTop || document.documentElement.scrollTop
            var timer = setInterval(function(){
                h2 = h2 - 10 -h2/5
                scrollTo(0,h2)
                if(h2<=0){
                    clearInterval(timer)
                }
            },50)
            
        }
    </script>
</body>
</html>